<?php if($this->main):?>
<?php echo $this->doctype() ?>
<?php 
	$storage = new Zend_Auth_Storage_Session();
	$data = $storage->read();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
    tinymce.init({
    	mode : "exact",
        elements:"editor",
        menubar: false,
        plugins: "autoresize",
        init_instance_callback: function(){
        ac = tinyMCE.activeEditor;

        ac.dom.setStyle(ac.getBody(), 'fontSize', '13px');
        
    	}
    	                
    });    
</script>

	
	<?php echo $this->headTitle() ?>
	<?php echo $this->headMeta() ?>
    <?php echo $this->headLink() ?>    
    <?php echo $this->headStyle() ?>
    <?php echo $this->headScript() ?>	
    <?php $url = $this->baseUrl();?>
    
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $this->dirImg;?>/favicon.ico" />
    
</head>
<body>
<input type="hidden" id="url" value="<?php echo $url;?>" />
<div id="header">
	<div id="inside">
        <a href="/" target="_top" style="margin-top: -10px;">
        	<img style="height: 50px;" src="<?php echo $this->dirImg;?>/logo.png">
        </a>      
        <!-- 
        <div id="switcher">            
            <div id="dropdown">
            	<div id="dropdowninside">
                    <input type="text" placeholder="Search">
                </div>
            </div>    
        
        </div>
        !-->      
        
        <div class="registration">
        
        <div class="signup" id="signup" style="display:none;">
        
        	<form enctype="application/x-www-form-urlencoded" method="post" _lpchecked="1" action="<?php echo $url;?>/registration/auth/signup">
        
           	<strong class="title">Tài khoản Otaha mới? Đăng ký</strong> 
             
            <div class="placeholding-input">
	          	<input type="text" id="signup-user-name" class="text-input" autocomplete="off" name="fullname" maxlength="20" placeholder="Tên đầy đủ">
	          	
        	</div> 
        	<div class="placeholding-input">
          		<input type="text" id="signup-user-email" class="text-input email-input" autocomplete="off" name="email" placeholder="Email">
          		
        	</div>
        	<div class="placeholding-input">
          		<input type="password" id="signup-user-password" class="text-input" name="password" placeholder="Password">          		
        	</div>
        	<button type="submit" class="btn signup-btn">
          		Tạo tài khoản Otaha
        	</button>       	
        	
        	</form>
        	
		</div>
		
		
		
        <?php if(!isset($data->displayname)):?>
        <a href="Javascript:void(0);" id="jointext" onclick="onRegistration('signup','signin');">Đăng ký</a>
        <?php else :?>
        
        <div class="pull-right">
        	
        	<ul class="nav">
        		<li>
        			<span class="dropdown-toggle" onclick="onRegistration('dropdown-acc','');">        			
        				<span class="new-wrapper">

						<i class="nav-session">
						
						</i>
						<i class="nav-new"></i>						        				
        				</span>        			
        				<span class="caret"></span>
        			</span>
        			<ul class="dropdown-menu" id="dropdown-acc">
        				<li class="dropdown-caret">
	        				<span class="caret-outer"></span>
	        				<span class="caret-inner"></span>
        				</li>
        				<li class="current-user">
        				
        				<a href="<?php echo $url?>/profile" data-nav="all_lists">Thiết lập tài khoản</a>
        				
        				</li>
        				<li class="dropdown-divider"></li>
        				<li class="current-user">
        				
        				<a href="<?php echo $url?>/registration/auth/logout" data-nav="all_lists">Thoát</a>
        				
        				</li>
        				
        			</ul>
        		</li>
        	</ul>
        </div>
        
        
        <?php endif;?>
        <div class="signin" id="signin" style="display:none;">     
        	
        	
        	<dib class="form-sign">
        	
        	<form enctype="application/x-www-form-urlencoded" method="post" _lpchecked="1" action="<?php echo $url;?>/registration/auth/login">
        	
        		<div class="username">
        			<input type="text" name="email" id="signin-email" class="text-input email-input" name="session[username_or_email]" title="email" autocomplete="on" tabindex="1" placeholder="email">
        			<!-- <label for="signin-email" class="placeholder">Username or email</label> -->
        		</div>
        		
        		<table class="pass-sign">
	        		<tbody>
	        			<tr>
	        				<td class="flex-table-primary">
	        					<div class="placeholding-input password flex-table-form">
                				<input type="password" name="password" id="signin-password" class="text-input flex-table-input text-password" name="session[password]" title="Password" tabindex="2" placeholder="password">
                				<!-- <label for="signin-password" class="placeholder text-password">Password</label> -->
              					</div>
	        				</td>
	        				<td class="flex-table-secondary">
              					<button type="submit" class="submit btn primary-btn flex-table-btn js-submit" tabindex="4">
                				Vào ngay
              					</button>
            				</td>
	        			</tr>
	        		</tbody>
        		</table>
        		
        		</form>
        	
        	</dib>
        
        </div>
        
        
        
        <?php if(!isset($data->displayname)):?>
        <a id="jointext" href="javascript:void(0);" onclick="onRegistration('signin','signup');">Đăng nhập</a>
        <?php else :?>
        <a href="<?php echo $url;?>/post?id=<?php echo $data->id;?>" id="jointext"><?php echo $data->displayname;?></a>
        
        <a href="#" id="jointext">
        	<?php if($data->avatar != ""):?>
			
				<img alt="noavatar" style="width: 20px; height: 20px;" src="<?php echo $url;?>/upload/<?php echo $data->avatar;?>">
				
			<?php else :?>
				<img alt="noavatar" style="width: 20px; height: 20px;" src="http://0.gravatar.com/avatar/98d7a2361501957b551a32fceca493a5?s=56&d=mm&r=G">
			<?php endif;?>
        	
        	</a>
        
        <?php endif;?>
 
        
        <!-- 
        
        <a id="jointext" href="<?php if(!isset($data->displayname)):?> <?php echo $url?>/registration/auth/login <?php else:?> <?php echo $url?>/post?id=<?php echo $data->id;?>&type=new<?php endif;?>" style="width: 85px;">
	        <span class="icons-pencil"></span>
	        <span style="font-weight: bold;" >Viết bài</span>	        
        </a>
        
        !-->
        
        </div>
    </div>
</div>

<div class="gl_container">

<div class="content">

<div>

<div class="mainContainer">

<?php if ($this->module != "landpage"):?>

<?php if ($this->module == "home"):?>
<div id="left-area" style="border: none; background: none;">	
<div class="sidebar">

	<h5>Channels</h5>
	
	<div class="textwidget">
	
		<ul>
		
		<?php if($data && $data->auth == 1):?>
			<li>
			
			<span style="float: left;padding-right: 3px;">
				<img style="width: 15px; height: 15px;" src="<?php echo $this->dirImg;?>/add.png" alt="" />
			</span>
			
			<a href="<?php if($data):?> <?php echo $url;?>/registration/index/chanel/?next=1 <?php else:?> <?php echo $url;?>/registration/auth/login <?php endif;?>" title="Tạo channel" >Tạo channel</a>
			
			</li>
			
		<?php endif;?>
			
		<!-- 
		<?php foreach( $this->list_category as $key => $val):?>
		
			<li>
			<a href="<?php echo $url;?>/?categoryid=<?php echo $val['id'];?>" title="<?php echo $val['name'];?>">			
			<?php echo $val["description"];?>
			
			 <span class="count">5</span>
			
			</a>
			</li>
			
			
		<?php endforeach;?>
		
		!-->
		
		<?php foreach( $this->list_chanel as $key => $val):?>
		
			<li>
			
			<span style="float: left;padding-right: 3px;">
				<img style="width: 20px; height: 20px;" src="<?php echo $url;?>/upload/<?php echo $val['logo'];?>" alt="" />
			</span>
			
			<a href="<?php echo $url;?>/chanel/?id=<?php echo $val['id'];?>" title="<?php echo $val['name'];?>">			
			<?php echo $val["name"];?></a>
			
			</li>
			
			
		<?php endforeach;?>
		
			
			
		</ul>
		
	</div>

</div>
</div>
<?php endif;?>
	
	<?php if ($this->module == "profile" && $this->user):?>
	<div id="left-area" style="margin-top: 10px;border: 1px solid rgba(0,0,0,.1); border-radius:6px;opacity: 0.9;">
	
	<div id="logo">

		<p>
		
			<a href="#" style="float: left;">
		
			<?php if($this->user["avatar"]):?>
			
				<img src="<?php echo $url;?>/upload/<?php echo $this->user["avatar"];?>" alt="<?php echo $this->user["displayname"]?>" style="width: 48px; height: 48px;padding:0; border: 1px solid rgba(0,0,0,.1); border-radius:6px; margin: 5px;">
				
			<?php else :?>
				<img alt="noavatar" style="width: 48px;padding:0; height: 48px;border: 1px solid rgba(0,0,0,.1); border-radius:6px; margin: 5px;" src="http://0.gravatar.com/avatar/98d7a2361501957b551a32fceca493a5?s=56&d=mm&r=G">
			<?php endif;?>
		
			</a>
		
		<p style="padding-top: 10px;"><b><?php echo $this->user["displayname"];?></b></p>
		
		</p>
			
		<?php if($this->user["company"] != ""): ?>
		
		<p class="info" style="clear: left;">
			<span class="icon-lock"></span>
			<span id="span_company">
				<a href="javascript:void(0);" onclick="onEdit('txt_company','span_company');"><?php echo $this->user["company"];?></a>
				
			</span>
			<input id="txt_company" type="text" style="display: none;" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn làm việc ở đâu?" onblur="updateProfile('txt_company','txt_school','txt_home');"  value="">
		</p>
		
		<?php else:?>
		
		<?php if ($data && $this->user["id"] == $data->id ):?>
		
		<p class="innerWrap info">
			<span class="icon-lock"></span>
			<span id="span_company" style="display: none">
			</span>
			<input id="txt_company" type="text" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn làm việc ở đâu?" onblur="updateProfile('txt_company','txt_school','txt_home');"  value="">
		</p>
		<?php endif;?>
		
		<?php endif;?>
		
		<?php if($this->user["school"] != ""): ?>
		
		<p class="info">
			<span class="icon-folder-close"></span>
			<span id="span_school">
				<a href="javascript:void(0);" onclick="onEdit('txt_school','span_school');"><?php echo $this->user["school"]?></a>				
			</span>
			<input id="txt_school" style="display: none;" type="text" id="txt_school" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn học trường nào?" onblur="updateProfile('txt_company','txt_school','txt_home');" value="">
		</p>
		
		<?php else:?>
		
		<?php if ($data && $this->user["id"] == $data->id ):?>
		
		<p class="innerWrap info">
			<span class="icon-folder-close"></span>
			<span id="span_school" style="display: none"></span>
			<input id="txt_school" type="text" id="txt_school" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn học trường nào?" onblur="updateProfile('txt_company','txt_school','txt_home');" value="">
		</p>
		
		<?php endif;?>		
		
		<?php endif;?>
		
		<?php if($this->user["home"] != ""): ?>
		
		<p class="info">
			<span class="icon-home"></span>
			<span id="span_home">
				<a href="javascript:void(0);" onclick="onEdit('txt_home','span_home');"><?php echo $this->user["home"];?></a>				
			</span>
			<input id="txt_home" style="display: none;" type="text" id="txt_home" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn lớn lên ở đâu?" onblur="updateProfile('txt_company','txt_school','txt_home');"  value="">
		</p>
		
		<?php else:?>
		
		<?php if ($data && $this->user["id"] == $data->id ):?>
		
		<p class="innerWrap info">
			<span class="icon-home"></span>
			<span id="span_home" style="display: none"></span>
			<input id="txt_home" type="text" id="txt_home" class="inputtext textInput DOMControl_placeholder"  placeholder="Bạn lớn lên ở đâu?" onblur="updateProfile('txt_company','txt_school','txt_home');"  value="">
		</p>
		
		<?php endif;?>
		
		<?php endif;?>
		
		<?php if($this->user["relation"] != ""): ?>
		
		<p class="info">
			<span class="icon-heart"></span>
			<span><?php echo $this->user["relation"];?></span>
		</p>	
		
		<?php endif;?>	
		
		<?php if ($data and $data->id == $this->user["id"]):?>
		
		<p>
			<form enctype="multipart/form-data" name="uploadcover" id="uploadcover" method="POST" action="<?php echo $url;?>/registration/index/uploadcover/">
			<label id="camera" class="ipt-form-upload-label" data-title="Insert Media" data-delay="{ show: 500, hide: 100 }" data-placement="bottom" style="width: 100px;" >

                   <span>Thay đổi background</span>

                   <span><input type="file"  id="myfile_cover" name="myfile"  /></span>

                   <div class="clearfix"></div>
                   
              </label>
              <input type="hidden" name="type" value="uploadcover" />
              <input type="hidden" name="idchanel" value="<?php echo $this->id;?>" />
			</form>
		</p>
		
		<?php endif;?>	
					
	</div>	
	
	</div>	
		
	<?php endif;?>
	
	
	<?php if ($this->module == "profile" && $this->chanel):?>
	<div id="left-area" style="margin-top: 10px;border: 1px solid rgba(0,0,0,.1); border-radius:6px;opacity: 0.9;">
	
	<div id="logo">

		
		<p>
		
			<a href="#" style="float: left;">
			
			<?php if($this->chanel["logo"]):?>
				
					<img src="<?php echo $url;?>/upload/<?php echo $this->chanel["logo"];?>" alt="<?php echo $this->chanel["name"]?>" style="width: 48px; height: 48px;border: 1px solid rgba(0,0,0,.1); border-radius:6px; margin: 5px;padding: 0;">
					
			<?php else :?>
					<img alt="noavatar" style="width: 48px; height: 48px;border: 1px solid rgba(0,0,0,.1); border-radius:6px; padding:0 ;margin: 5px;" src="http://0.gravatar.com/avatar/98d7a2361501957b551a32fceca493a5?s=56&d=mm&r=G">
			<?php endif;?>
			
			
		
			</a>
		
		<p style="padding-top: 10px;"><b><?php echo $this->chanel["name"];?></b></p>
		
		</p>
			
		<p class="info" style="clear: left;">
			<span class="icon-user"></span>
			<span>
			<?php echo $this->chanel["name"];?>
			</span>
		</p>
		
		<?php if($this->chanel["description"] != ""): ?>
		
		<p class="info">
			<span class="icon-list-alt"></span>
			<span id="span_des">
				<?php echo $this->chanel["description"];?>				
			</span>
			
		</p>
		
		<?php endif;?>
		
		<?php if($this->chanel["location"] != ""): ?>
		
		<p class="info">
			<span class="icon-map-marker"></span>
			<span id="span_des">
				<?php echo $this->chanel["location"];?>				
			</span>			
		</p>
		
		<?php endif;?>
		
		<p class="info">
		<img src="http://venture-lab.org/images/icons/team-icon.png" width="18"  style="float: left;padding: 3px 0 0 0;" />
		<span class="number"><?php echo $this->followchanel->countFollow($this->chanel["id"]);?></span>
		
		<?php if ($data == FALSE || ($data && $this->followchanel->ischeckFollow($this->chanel["id"],$data->id)) == 0):?>
		
		<a id="btn-follow<?php echo $this->chanel["id"];?>" href="javascript:void(0);" class="reblog_follow_button" style="color: #fff; font-size: 11px;line-height: 12px;padding-left: 10px;" data-tumblelog-name="<?php echo $this->chanel["name"]?>" title="Kết nối <?php echo $this->chanel["name"]?>" onclick="followChanel('<?php echo $this->chanel["id"];?>');"><i>Kết nối</i></a>
		
		<?php endif;?>
		
		</p>
		
		<p class="info">		
		<img src="http://s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif"  width="18"  style="background: no-repeat url(//s.ytimg.com/yts/imgbin/www-hitchhiker-vflX22WRH.png) -227px -133px;float: left;padding: 3px 0 0 0;margin-top: 3px;" />
		<span class="number">
		
  		<?php echo $this->like_chanel->countLike($this->chanel["id"],"like");?>
  		
  		</span>
  		<?php if ($data == FALSE || ($data && $this->like_chanel->ischeckLike($this->chanel["id"],$data->id)) == 0):?>
		<a id="like-chanel" href="javascript:void(0);" class="reblog_follow_button" style="color: #fff; font-size: 11px;line-height: 12px;padding-left: 10px;" data-tumblelog-name="<?php echo $this->chanel["name"]?>" title="Thích <?php echo $this->chanel["name"]?>" onclick="<?php if($data):?>likechanel('chanel','like','<?php echo $this->chanel["id"];?>'); return false; <?php else:?> login();  <?php endif;?>"><i>Thích</i></a>
		<?php endif;?>
		</p>
		
		<?php if($data && $this->chanel["userid"] == $data->id):?>
		
		<p>
			<form enctype="multipart/form-data" name="uploadcover" id="uploadcover" method="POST" action="<?php echo $url;?>/chanel/index/uploadcover/">
			<label id="camera" class="ipt-form-upload-label" data-title="Insert Media" data-delay="{ show: 500, hide: 100 }" data-placement="bottom" style="width: 100px;" >

                   <span>Thay đổi background</span>

                   <span><input type="file"  id="myfile_cover" name="myfile"  /></span>

                   <div class="clearfix"></div>
                   
              </label>
              <input type="hidden" name="type" value="uploadcover" />
              <input type="hidden" name="idchanel" value="<?php echo $this->id;?>" />
			</form>
		</p>
					
		<?php endif;?>
					
	</div>	
	
	</div>	
		
	<?php endif;?>
		


<div id="content-area" class ="clearfix">

	<div id="content_right">
	
	<?php echo $this->layout()->content ?>
	
		
	</div>

</div>

<?php else:?>

	<?php echo $this->layout()->content ?>

<?php endif;?>

</div>
</div>
</div>
</div>

<div id="footer">

	<ul class="clearfix">
	<li><a href="<?php echo $url;?>">
		<img src="<?php echo $this->dirImg?>/home.gif" alt="HOME" width="40" height="11" class="imgover" hsrc="images/btn_footer01_o.gif"></a>
	</li>
	</ul>
	<address><img src="<?php echo $this->dirImg?>/txt_copyright.gif" alt="Copyright (C) Otaha. All rights reserved." width="306" height="10"></address>

</div>

<script type="text/javascript">

	$(document).mouseup(function (e)
	{
	    var container = $("#dropdown-acc");
	    var container1 = $("#signin");
	    var container2 = $("#signup");
	    
	
	    if (container.has(e.target).length === 0)
	    {
	        container.hide();
	        
	     
	    }
	    if (container1.has(e.target).length === 0){

	    	container1.hide();
		    
	    }

	    if (container2.has(e.target).length === 0){

	    	container2.hide();
		    
	    }
	    
	});

	
	$(document).ready(function(){



		$("#placeholder").click(function(){
		    $(this).hide();
		    $(this).css("z-index","none");
		    tinyMCE.get('editor').focus();
		    
		});
					

		var options = {
                //target:        '#tutor',   // target element(s) to be updated with server response
                beforeSubmit:  showRequest,  // pre-submit callback
                success:       showResponse  // post-submit callback
               
            };

		$('#myfile').change(function() {

			var content = tinyMCE.activeEditor.getContent();

			$("#editor").val(content);

			$('#hd_post').val('preview');

			$("#wait").show();
		    
			$('#myForm').submit();

			
		    
		    
		});

		$('#btn-publish').click(function() {

			var link_youtube = $("#txt_link_youtube").val();

			if(link_youtube){

				var id_youtube = YouTubeGetID(link_youtube);

				$("#id_youtube").val(id_youtube);
				
			}
						
			var content = tinyMCE.activeEditor.getContent();

			$("#editor").val(content);
			
			$('#hd_post').val('publish');

			$("#wait").show();
		    
			$('#myForm').submit();
		    
		    
		});

		

		// bind form using 'ajaxForm'
		 // bind to the form's submit event 
	    $('#myForm').submit(function() { 
	        // inside event callbacks 'this' is the DOM element so we first 
	        // wrap it in a jQuery object and then invoke ajaxSubmit 
	        $(this).ajaxSubmit(options); 
	 
	        // !!! Important !!! 
	        // always return false to prevent standard browser submit and page navigation 
	        return false; 
	    }); 
	
        
            // pre-submit callback
            function showRequest(formData, jqForm, options) {
            
                var queryString = $.param(formData);

            
                //alert('About to submit: \n\n' + queryString);

            
                return true;
            }

            // post-submit callback
            function showResponse(responseText, statusText, xhr, $form)  {

                var module = $('#hd_post').val();

                if (module == "preview"){

                	$("#media").append(responseText);
                	
                }
                else{

                	$("#main-post").prepend(responseText);
                	$("#media").html("");
                	tinymce.get('editor').setContent("");
                	$("#placeholder").show();
                	
                }

                $("#wait").hide();  
                $("#txt_link_youtube").val("");
                $("#txt_link_youtube").hide();

                //Send Mail Feed Ajax

                var idchanel = $("#idchanel").val();

                if (idchanel != ""){

                	sendMailFeed(idchanel);
                	
                }
                                  
            }
			
	});
</script>



<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-40899090-1', 'otaha.com');
  ga('send', 'pageview');

</script>


</body>
</html>

<?php else :?>

<?php echo $this->layout()->content ?>



<?php endif;?>
